package com.wufan.day03;

/**
 * 万物皆对象
 * @author SongWufan
 * @date 2021/3/7 17:04
 */
public class InstanceTest {
    public static void main(String[] args) {
        Phone p = new Phone();
        System.out.println(p);
        p.sendEmail();
        p.playGame();

        //匿名对象
        new Phone().sendEmail();
        new Phone().playGame();
        new Phone().price = 1000;
        new Phone().showPrice();

        PhoneMall phoneMall = new PhoneMall();
        phoneMall.show(new Phone());
    }
}

class PhoneMall{
    public void show(Phone phone) {
        phone.sendEmail();
        phone.playGame();
    }
}

class Phone{
    double price;

    public void sendEmail() {
        System.out.println("发送邮件");
    }

    public void playGame() {
        System.out.println("玩游戏");
    }

    public void showPrice() {
        System.out.println("价格："+price);
    }
}
